package com.example.demo.service.impl;

import com.example.demo.model.supplier;
import com.example.demo.repository.supplierRepository;
import com.example.demo.service.supplierService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.transaction.Transactional;
import java.util.List;
@Transactional//添加事务管理。
@Service
public class supplierServiceImpl implements supplierService {


    @Resource
    private supplierRepository suppRepository;

    @Override
    public supplier findById(String id) {
        return suppRepository.findById(id).get();
    }

    @Override
    public List<supplier> findAll() {
        return suppRepository.findAll();
    }

//    @Override
//    public List<supplier> findBySnameIsNull() {
//        return suppRepository.findBySnameIsNull();
//    }//查找名字为空的
    @Override
    public void delete(String id) {
        suppRepository.deleteById(id);
    }

    @Override
    public void deleteAll()
   {
       suppRepository.deleteAll();
   }

    @Override
    public supplier save(supplier SUPP) {
        return suppRepository.save(SUPP);
    }

    @Override
    public void deleteAllBySnameIsNull()
   {
    suppRepository.deleteAllBySnameIsNull();
   }

}
